package com.ustb.springboot.controller;

import com.ustb.springboot.common.utils.R;
import com.ustb.springboot.entity.QuestionScoreEntity;
import com.ustb.springboot.service.QuestionScoreService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;


/**
 * @author pyn
 * @date 2022-05-17 11:26:55
 */
@RestController
@RequestMapping("questionscore")
public class QuestionScoreController {

    @Autowired
    private QuestionScoreService questionScoreService;

    /**
     * 保存
     */
    @RequestMapping(value = "/save")
    @RequiresPermissions("questionscore:save")
    public R save(HttpServletRequest request, @RequestBody QuestionScoreEntity questionScore) {
        return questionScoreService.save(request, questionScore);
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("questionscore:update")
    public R update(@RequestBody QuestionScoreEntity questionScore) {
        return questionScoreService.updateById(questionScore) ? R.ok(20000, "更新成功") : R.error(2000, "更新失败");
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("questionscore:delete")
    public R delete(@RequestBody Map<String, Object> body) {
        return questionScoreService.delete(body);
    }

}
